package main

import (
	"errors"
	"github.com/davecgh/go-spew/spew"
)

/*
go-spew 可以以一种非常友好的方式输出完整的数据结构信息
go get -u github.com/davecgh/go-spew/spew

go-spew有三个 Dump 系列函数：

	Dump() 标准输出到os.Stdout
	Fdump() 允许输出自定义io.Writer
	Sdump() 输出的结果作为字符串返回
*/
type S struct {
	S2 *S2
	I  *int
}

type S2 struct {
	Str string
}

func main() {
	s := "GoCN"
	i := 2
	f := []float64{1.1, 2.2}
	m := map[string]int{"a": 1, "b": 2}
	e := errors.New("new error")
	ss := S{S2: &S2{Str: "xxx"}, I: &i}
	spew.Dump(s, i, f, m, e, ss)
	/*
		(string) (len=4) "GoCN"
		(int) 2
		([]float64) (len=2 cap=2) {
		 (float64) 1.1,
		 (float64) 2.2
		}
		(map[string]int) (len=2) {
		 (string) (len=1) "a": (int) 1,
		 (string) (len=1) "b": (int) 2
		}
		(*errors.errorString)(0xc00010e1b0)(new error)
		(main.S) {
		 S2: (*main.S2)(0xc00010e1c0)({
		  Str: (string) (len=3) "xxx"
		 }),
		 I: (*int)(0xc0001021c0)(2)
		}
	*/
}
